﻿using System;

namespace ConditionTreeTestStand.Nodes
{
  public class SecondOperandStringViewModel : SecondOperandViewModel<string>
  {
    public SecondOperandStringViewModel(NodeViewModel owner)
      : base(owner)
    {
      SecondOperand = "";
    }

    #region ' IsEmpty Property (change notification) '
    
    public bool IsEmpty
    {
      get { return _isEmpty; }
      set
      {
        if (_isEmpty == value) return;
        _isEmpty = value;
        NotifyOfPropertyChange(() => IsEmpty);
      }
    }

    private bool _isEmpty;

    #endregion

    protected override void OnSecondOperandChanged()
    {
      if (SecondOperand == null)
      {
        SecondOperand = "";
        return;
      }
      
      base.OnSecondOperandChanged();
      IsEmpty = string.IsNullOrWhiteSpace(SecondOperand);
    }

    public override string StrValue
    {
      get { return SecondOperand; }
      set { SecondOperand = value; }
    }
  }
}